package com.example.sy07_broadcast;

import androidx.appcompat.app.AppCompatActivity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.os.BatteryManager;
import android.os.Bundle;
import android.util.Log;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        PowerConnectionReceiver pcr = new PowerConnectionReceiver();
        IntentConnectionReceiver icr = new IntentConnectionReceiver();

        //设置意图过滤器
        IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
        //注册广播接收者
        Intent batteryStatus = registerReceiver(pcr, ifilter);

        IntentFilter ifilter2 = new IntentFilter();
        ifilter2.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        Intent IntentStatus=registerReceiver(icr,ifilter2);
    }
}

